<?php
namespace Admin\Controller;
use Think\Controller;
class UserController extends Controller{

	//用户信息
	public function userinfo(){
		$db = D('User');
		$res = $db->select();
		$this->assign('res',$res);
		$this->display('userinfo');
	}

	//查看用户信息
	public function usercheck(){
		$id = I('get.id');
		$db = D('User');//连接数据库
		$res = $db->where("id=%d",$id)->select();
		$this->assign('res',$res);
		$this->display();
	}

	//添加用户
	public function useradd(){
		if(IS_POST){
		  $db = D('User');//连接数据库
		  $data = $db->create();
		  $res = $db->add($data);
		  $this->userinfo();
		} else {
		  $this->display();
		}	
	}


	//修改用户信息
	public function usermodify(){
		if(IS_POST){
			$id = I('get.id');
			$db = D('User');
			$data = $db->create();
			$db->where("id=%d",$id)->save($data);
			$this->userinfo();
		} else {
			$id = I('get.id');
			$db = D('User');
			$res = $db->where("id=%d",$id)->select();
			$this->assign('res',$res);
			$this->display();
		}
	}
	
	//删除用户
	public function userdel(){
		$id = I('get.id');
		$db = D('User');
		$res = $db->where("id=%d",$id)->delete();
		//$this->assign('res',$res);
		$this->userinfo();
	}


/*		//用户信息
	public function userinfo(){
		$db = D('User');
		$res = $db->select();
		$this->assign('res',$res);
		$this->display('userinfo');
	}*/
}

?>